import java.util.Scanner;

public class Main1737 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n= sc.nextInt();
        for (int i=1000;i<=n;i++){
            int a=i/1000;//1
            int b=i/100%10;//2
            int c=i%100/10;//3
            int d=i%100%10;//4
            if (d==b&&a==c){
                if (d==1||d==3||d==5||d==7 ||d==9){
                    System.out.println(i);
                }
            }
        }
    }
}

